//把配置项单独处理
// import store from '/store/index.js'; //vuex  
let server_url = 'https://car.egretloan.com/addons/shopro/'; //请求地址
let token = uni.getStorageSync('userInfo').token; //凭证
// process.env.NODE_ENV === 'http://h5.luckykey.online/api/'; //环境配置
function service(options = {}) {
	// store.state.token && (token = store.state.token); //从vuex中获取登录凭证
	options.url = `${server_url}${options.url}`;
	//配置请求头
	options.header = {
		'content-type': 'application/x-www-form-urlencoded',
		'token': `${token}`
	};
	return new Promise((resolved, rejected) => {
		//成功
		options.success = (res) => {
			resolved(res.data);
		}
		//错误
		options.fail = (err) => {
			rejected(err);
		}
		uni.request(options);
	});
}
export default service;
